﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace game
{
    [StructLayout(LayoutKind.Sequential)]
    public struct BillboardData
    {
        public Vector3 Position;
        public Vector2 TexCoord;
        public Vector2 Offset;
        public Vector3 Axis;
        public Color Color;
        public float Energy;

        public static VertexElement[] VertexElements;
        public static VertexDeclaration VertexDecl;
        public static int SizeInBytes { get; private set; }

        static BillboardData()
        {
            VertexElements = new VertexElement[] { // must have the same format as Particle struct
                    new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
                    new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
                    new VertexElement(0, 20, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),               
                    new VertexElement(0, 28, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 2),               
                    new VertexElement(0, 40, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0),               
                    new VertexElement(0, 44, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 3),               
            };

            VertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice, VertexElements);

            SizeInBytes = 12 + 8 + 8 + 12 + 4 + 4;
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct AnimatedBillboardData
    {
        public Vector3 Position;
        public Vector2 TexCoord1;
        public Vector2 TexCoord2;
        public Vector2 Offset;

        public static VertexElement[] VertexElements;
        public static VertexDeclaration VertexDecl;
        public static int SizeInBytes { get; private set; }

        static AnimatedBillboardData()
        {
            VertexElements = new VertexElement[] { // must have the same format as Particle struct
                    new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
                    new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
                    new VertexElement(0, 20, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),               
                    new VertexElement(0, 28, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 2),                           
            };

            VertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice, VertexElements);

            SizeInBytes = 12 + 8 + 8 + 8;
        }
    }
}
